<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/work_today.css" />
 <link rel="stylesheet" href="${staticServer}/css/lanrenzhijia.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/infopad.js?2.2"></script>
<script>
function starquery(){
	window.location.href="${contextPath}/index/usernamesList.htm?nickname="+$("#nickname").val()+"&date="+$("#dates").val();
}
</script>
<style>
	.Zebra_DatePicker {
    	z-index: 99999;
	}
	.theme-popover{
		height: 460px;
	}
</style>
<script>
		function addPerformanceInfo(id){
        	$("#id").val(id);
        	$("#username").val("");
			$("#date").val("");
			for(var i=1;i<21;i++){
				$("#username"+i).val("");
				$("#pusername"+i).val("");
			}
			
        	if(id!=null && id!=""){
        		$.post("${contextPath}/index/get_usernames.json", {
                	"id":id
				}, function(ms) {
					var usernames = ms.usernames;
					if(usernames!=null){
						$("#username").val(usernames.username);
						$("#date").val(usernames.date);
						var myArray=new Array()
						myArray = (usernames.usernames).split(",");
						if(myArray!=null){
							var j = 0;
							for(var i=0;i<myArray.length;i++){
								j = i+1;
								$("#username"+j).val(myArray[i]);
							}
						}
						
						var myArray2=new Array()
						myArray2 = (usernames.usernames2).split(",");
						if(myArray2!=null){
							var j = 0;
							for(var i=0;i<myArray2.length;i++){
								j = i+1;
								$("#pusername"+j).val(myArray2[i]);
							}
						}
					}
                });
        	}
        	
                
			$('.theme-popover-mask').fadeIn(100);
           	$('.theme-popover').slideDown(200);
            $('.theme-poptit .close').click(function(){
            $('.theme-popover-mask').fadeOut(100);
                $('.theme-popover').slideUp(200);
            })
        }
        
        function save(){
        		var id = $("#id").val();
                var username = $("#username").val();
                var date = $("#date").val();
                var usernames = $( "#username1" ).val()+","+$( "#username2" ).val()+","+$( "#username3" ).val()+","+$( "#username4" ).val()+","+
					$( "#username5" ).val()+","+$( "#username6" ).val()+","+$( "#username7" ).val()+","+$( "#username8" ).val()+","+
					$( "#username9" ).val()+","+$( "#username10" ).val()+","+$( "#username11" ).val()+","+$( "#username12" ).val()+","+
					$( "#username13" ).val()+","+$( "#username14" ).val()+","+$( "#username15" ).val()+","+$( "#username16" ).val()+","+
					$( "#username17" ).val()+","+$( "#username18" ).val()+","+$( "#username19" ).val()+","+$( "#username20" ).val();
                
                var pusernames = $( "#pusername1" ).val()+","+$( "#pusername2" ).val()+","+$( "#pusername3" ).val()+","+$( "#pusername4" ).val()+","+
					$( "#pusername5" ).val()+","+$( "#pusername6" ).val()+","+$( "#pusername7" ).val()+","+$( "#pusername8" ).val()+","+
					$( "#pusername9" ).val()+","+$( "#pusername10" ).val()+","+$( "#pusername11" ).val()+","+$( "#pusername12" ).val()+","+
					$( "#pusername13" ).val()+","+$( "#pusername14" ).val()+","+$( "#pusername15" ).val()+","+$( "#pusername16" ).val()+","+
					$( "#pusername17" ).val()+","+$( "#pusername18" ).val()+","+$( "#pusername19" ).val()+","+$( "#pusername20" ).val();
                
                
                if(username==""){
					infopad.err("请选择接销售主管!");
					return;
				}
                $.post("${contextPath}/index/add_usernames.json", {
                	"id":id,
					"username":username,
					"usernames":usernames,
					"pusernames":pusernames,
					"date":date
				}, function(ms) {
					 if (ms.msg=="1"){
                         infopad.msg("添加成功");
                         location.reload();
                     }else if (ms.msg=="0"){
                         infopad.err("该记录已经存在!");
                     }
                });
        }
        
        function addAll(){
            	var date1 = $("#date1").val();
                var date2 = $("#date2").val();
                $.post("${contextPath}/index/add_usernames_bydate.json", {
					"date1":date1,
					"date2":date2
				}, function(ms) {
					 if (ms.msg=="1"){
                         infopad.msg("添加成功");
                         location.reload() ;
                     }else if (ms.msg=="2"){
                         infopad.err("该记录已存在!");	
                     }else if (ms.msg=="0"){
                         infopad.err(date1+"没有记录!");
                     }
                });
        }
        
        var deleteUsernames = function(id){
        	if(confirm("确定删除？删除后无法恢复。")){
        		$.post("${contextPath}/index/delate_usernames.json", {
					"id":id
				}, function(ms) {
					 if (ms.msg=="1"){
                         infopad.msg("删除成功");
                         $("#"+id).remove();
                     }
                });
        	}
        }
</script>
</head>

<body>
<input type="hidden" id="id" value="">
	<div id="home_link">
		<ul>
			<li>竞思教育网络办公系统 v2.0 beta</li>
			<li>&gt;</li>
			<li>工作管理</li>
			<li>&gt;</li>
			<li class="current">特殊部门工作情况</li>
		</ul>
	</div>
	<div id="container">
		<div id="title">部门工作情况</div>
		
		<table class="form_table">
			<tbody>
			<tr class="even_row">
				<td>
					<label>姓名：</label>
					<input type="text" id="nickname" size="15" value="" placeholder="请输入姓名">
					<input type="text" id="dates" size="15" maxlength="20" rel="DATE::Y-m" />
					<input type="button" value=" 查询 " onclick="starquery()">
					<input type="button" value=" 添加下属 " onclick="addPerformanceInfo()">
					
					<label for="nickname">复制</label>
               		<input type="text" id="date1" size="15" maxlength="20" rel="DATE::Y-m" />
               		<label for="nickname">到</label>
               		<input type="text" id="date2" size="15" maxlength="20" rel="DATE::Y-m" />
               		<input type="button" value=" 确定 " onclick="addAll()" />
				</td>
			</tr>
			</tbody>
		</table>
		
		<table>
			<tr class="fields">
				<th width="100">销售主管</th>
				<th width="100">中心地址</th>
				<th width="100">日期</th>
				<th width="100">手下员工</th>
				<th width="50">操作</th>
			</tr>
			
			
			<#list list as list>
				<tr class="even_row" id="${list.id}">
					<td align="center">${list.nickname}</td>
					<td align="center">${list.center}</td>
					<td align="center">${list.date}</td>
					<td align="center">${list.nicknames}</td>
					<td align="center">
						<a href="#" onclick="addPerformanceInfo(${list.id})">编辑下属</a>-
						<a href="#" onclick="deleteUsernames(${list.id})">删除</a>
					</td>
				</tr>
			</#list>
			
			
		</table>
	</div>

<div class="theme-popover">
    <div class="theme-poptit">
        <a href="javascript:;" title="关闭" class="close">×</a>
        <h3>给销售主管添加下属</h3>
    </div>
    <div class="theme-popbod dform">
        <form class="theme-signin" >
            <ol>
                <li><strong>销售主管：</strong>
                    <select id="username">
                    <#if ulist??>
                    	<option value="">请选择</option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}（${list.regions}-${list.job}）</option>
                        </#list>
                    </#if>
                    </select>
				</li>
				
                <li><strong>&nbsp;属下老师 ：</strong>
                	<select id="username1">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username2">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username3">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username4">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username5">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username6">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username7">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username8">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username9">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username10">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username11">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username12">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username13">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username14">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username15">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username16">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username17">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username18">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username19">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="username20">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                <li>
                
                <li><strong>&nbsp;属下老师<br/>(用于评分) ：</strong>
                	<select id="pusername1">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername2">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername3">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername4">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername5">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername6">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername7">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername8">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername9">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername10">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername11">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername12">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername13">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername14">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername15">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername16">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername17">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername18">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername19">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                    <select id="pusername20">
                    <#if ulist??>
                    	<option value=""></option>
                        <#list ulist as list>
                            <option value="${list.username}">${list.nickname}</option>
                        </#list>
                    </#if>
                    </select>
                <li>
                <li><strong>&nbsp;日期 ：</strong>
                	 <input type="text" id="date" value="" size="15" maxlength="20" rel="DATE::Y-m" />
                <li>
                    <input class="btn btn-primary" type="button"  onclick="save()" value=" 保 存 " /></li>
            </ol>
        </form>
    </div>
</div>
	<div id="pager" style="width: 820px;">
	<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/index/usernamesList.htm?currPage=${currpage-1}">上一页</a></li>
					</#if>
					
		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>  
	           <#if currpage==index_up > 
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/index/usernamesList.htm?currPage=${index_up}">${index_up}</a></li>  
	           </#if>  
			</#list>  
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>  
	           	<#if currpage==index_up >  
	            	<li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/usernamesList.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
	           	</#list>  
	           	<li>...</li>
	           	<li><a href="${contextPath}/index/usernamesList.htm?currPage=${pagetotal}">${pagetotal}</a></li>  
				
			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >	
				<li><a href="${contextPath}/index/usernamesList.htm?currPage=1">1</a></li>  
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/usernamesList.htm?currPage=${index_up}">${index_up}</a></li>  
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/index/usernamesList.htm?currPage=${pagetotal}">${pagetotal}</a></li>   
			<#else>
				<li><a href="${contextPath}/index/usernamesList.htm?currPage=1">1</a></li> 
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/usernamesList.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/index/usernamesList.htm?currPage=${currpage+1}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
	</#if>
	</ul>
	</div>
	<div class="emptyline clear"></div>
</body>
</html>